<template>
  <div class="ProvincialWeight">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">各省重量统计</span>
      </div>
      <s-table
        :table="table"
        @http="tableWatch">
        <el-form-item slot="multiSelect" label="多选操作" prop="multiSelect" v-if="table.multiSelect">
          <el-row>
            <el-col :span="8">
              <el-button size="small" type="info" @click="tableExport('')">多选导出</el-button>
            </el-col>
          </el-row>
        </el-form-item>
      </s-table>
    </el-card>
  </div>
</template>

<script>
  import {AutoVue} from '~/plugins/Tools';
  export default AutoVue({
    name: 'journaling_stockCountDaily-FEcarWms',
    head: {
      'title': '各省重量统计',
      'meta': [
        { 'hid': 'description', 'name': 'description', 'content': '乐速科技平台 各省重量统计 查看各省重量统计信息' },
      ],
    },
    data: {
      table: {
        column: [
          {'label': '省份', 'prop': 'province', 'minWidth': '0px'},
          {'label': '0-1KG含1', 'prop': 'oneKg', 'minWidth': '0px'},
          {'label': '1-2KG含2', 'prop': 'twoKg', 'minWidth': '0px'},
          {'label': '2-3KG含3', 'prop': 'threeKg', 'minWidth': '0px'},
          {'label': '3以上', 'prop': 'fourKg', 'minWidth': '0px'},
          {'label': '汇总', 'prop': 'provinceSummary', 'minWidth': '0px'},
        ],
        url: '/wmsStatisticalWeight/baseSelectPage',
        key: 'id',
        tableColumn: 6,
        option: {
          cjsj: '',
        },
        muti: true,
      },
    },
    transition: 'slide-fade',
    methods: {
      tableExport (row) {
        let tableRef = 'table';
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          console.log('this[tableRef].multipleSelection', this[tableRef].multipleSelection);
          this[tableRef].multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        console.log('ids', ids);
        this.$confirm('您将导出各省重量统计。', '确认导出？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              let option = Object.assign({}, this['autoVue_' + tableRef]);
              await this.p({
                url: '/wmsStatisticalWeight/exportStatisticalWeight',
                method: 'post',
                responseType: 'blob',
                data: {
                  ids,
                  ...option,
                },
              });
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
    },
    mounted: function () {
      this.tableWatch('table');
    },
  });
</script>

<style scoped lang="scss">
  .card-bottom{
    width: 100%;
    height: 100px;
    margin-top: 20px;
    border: 1px solid #eef1f6;
  }
  .card-bottom-div, .card-bottom-div1{
    min-width: 100px;
    min-height: 56px;
    float: left;
    margin-top: 16px;
    padding: 0 24px;
    border-right: 1px solid #DCDFE6;
  }
  .card-bottom-div1{
    padding-top: 16px;
  }
  .card-bottom-div span{
    display: block;
    height: 30px;
    margin: 8px 24px;
    margin-top: 0px;
  }
  .card-bottom-div span:first-child{
    font-size: 1.1rem;
  }
</style>

<style lang="scss">
  .ProvincialWeight{
    width: 88vw;
    float: left;
  }
</style>

